<?
include('config.php');

// table name 
$tbl_name=temp_members_db;

// Random confirmation code 
$confirm_code=md5(uniqid(rand()));

// values sent from form 
$naam=$_POST['naam'];
$adres=$_POST['adres'];
$woonplaats=$_POST['woonplaats'];
$postc=$_POST['postc'];
$telefoon=$_POST['telefoon'];
$email=$_POST['email'];
$password=$_POST['password'];
$password=md5($password);

// Insert data into database 
$sql="INSERT INTO $tbl_name(confirm_code, naam, adres, woonplaats, postc, telefoon, email, password )VALUES('$confirm_code', '$naam', '$adres', '$woonplaats', '$postc', '$telefoon', '$email', '$password')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email 
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: group 3 productions <info@group3productions.info>";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.group3productions.info/confirmation.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

}

// if not found 
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>